package com.yhf.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yhf.mapper.PermissionMapper;
import com.yhf.model.Permission;
import com.yhf.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {
    @Autowired
    private PermissionMapper permissionMapper;
    @Override
    public List<Permission> findAll(int id) {
        //根据parentid查所有
        List<Permission> list = permissionMapper.findAll(id);
        for (Permission permission : list) {
            List<Permission> children;
            //通过递归的查询
            children=findAll(permission.getId());
            permission.setChildren(children);
        }
        System.out.println(list);
        return list;
    }
}
